<?php

namespace app\model\zs;

use think\Model;

class ZsBallRace extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'ball_races';

    // 设置当前模型的数据库连接
    protected $connection = 'zs';

    // 自动写入时间的类型
    protected $autoWriteTimestamp = 'datetime';

    // 定义时间戳字段名
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';

    const RACE_END_BLUE = 1;
    const RACE_END_RED = 2;
    const RACE_END_DRAW = 3;

    public function blueTeam()
    {
        return $this->belongsTo(ZsBallTeam::class, 'blue_team_id', 'id');
    }

    public function redTeam()
    {
        return $this->belongsTo(ZsBallTeam::class, 'red_team_id', 'id');
    }

    public static function raceTypeRels()
    {
        return [
            1 => '1/8决赛',
            2 => '1/4决赛',
            3 => '半决赛',
            4 => '决赛',
        ];
    }
}
